<template>
    <transition name="fade">
        <div :class="{ 'myPopup': !visible, 'myPopup_active': visible }" @click="close">
            <!-- <div class="myPopupBox" :style="{ alignItems: position, }"> -->
            <!-- <div :class="{ 'box': !visible, 'box_active': visible }" @click.stop> -->
            <!-- <div style="height: 100px;"></div> -->
            <slot></slot>
            <!-- <div style="height: 100px;width: 100px"></div> -->
            <!-- </div> -->
            <!-- </div> -->
        </div>
    </transition>
</template>

<script>
import { httpService } from "@/utils/httpService";
import { formatTime1 } from "@/utils/dateFormat";

export default {
    props: {
        visible: {
            type: Boolean,
            default: true
        },
        position: {
            type: Boolean,
            default: false
        },
    },
    data() {
        return {
            // visible: false,
            visiFlag: false,
            queryData: {},
            approveData: [],
        };
    },
    components: {

    },
    watch: {
        close() {
            this.$emit('update:popupFalg', false);
        },
        visible(val) {
            if (val) {
                this.disableScroll();
            } else {
                this.enableScroll();
            }
        }
    },
    mounted() {

    },
    methods: {
        disableScroll() {
            const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
            document.body.style.overflow = 'hidden';
            document.body.style.paddingRight = `${scrollBarWidth}px`;
        },
        enableScroll() {
            document.body.style.overflow = '';
            document.body.style.paddingRight = '';
        },
        close() {
            this.$emit("close");
        },

    }
}
</script>

<style scoped>
* {
    margin: 0;
    padding: 0;
}

.flex {
    display: flex;
    align-items: center;
}

.myPopup {
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: -1;
    opacity: 0; 
    transition: all 0.3s ease;
}

.myPopup_active {
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 999;
    opacity: 1;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    overflow: auto;
}

.myPopup_active::-webkit-scrollbar {
    width: 0 !important;
}

.myPopupBox {
    display: flex;
    align-items: center;
}

/* .box {
    padding: 100px 0;
    transform: scale(0);
}

.box_active {
    padding: 100px 0;
    transform: scale(1);
} */


.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}
</style>